<template>
  <div class="PersonIndexSpreadtrum tPage">
    <div v-if="spreadtrum_list.length>0">
      <div v-for="(v,k) in spreadtrum_list">
        <Item01 :pInfo="v" :is_me="dUserinfo.is_me"></Item01>
      </div>
    </div>
    <GetMore @getmore="get_spreadtrum_list" ref="GetMore" :getDataListDoing="getDataListDoing"></GetMore>
  </div>
</template>
<script>
import Item01 from "../../components/spreadtrum/item01";
import GetMore from "../../components/buttons/GetMore";

export default {
  name:"Spreadtrum",
  components: {GetMore,Item01},
  data(){
    return {
      page:1,
      spreadtrum_list:[],
      getDataListDoing:0,
      dUserinfo:[]
    }
  },
  methods:{
    get_spreadtrum_list(){
      let _this = this
      if (!_this.dUserinfo.uid)return false
      if (_this.getDataListDoing)return false;
      _this.getDataListDoing=1
      let params = {page:_this.page,create_uid:_this.dUserinfo.uid}
      if(_this.dUserinfo.is_me)params['datatypec']=-1
      console.log(params);
      myjs.get_spreadtrum_list(params,function(data){
        _this.spreadtrum_list=_this.spreadtrum_list.concat(data.data)
        _this.page++
        _this.getDataListDoing=0
      },function(){
        _this.$refs.GetMore.setNoMore()
        _this.getDataListDoing=0
      })
    }
  },
  mounted(){
    let _this=this
    setTimeout(function(){
      _this.dUserinfo = _this.$store.getters.getUserinfo
      if (!_this.dUserinfo){
        _this.$router.push({name:"PersonIndex"})
      }
      _this.get_spreadtrum_list()
    },500)
  },
  created() {
    let _this=this
    _this.$nextTick(function(){
      $(window).scroll(function(){
        if (_this.$route.name!==_this.$options.name)return false
        let scrollTop = $(this).scrollTop();
        let scrollHeight = $(document).height();
        let windowHeight = $(this).height();
        if(scrollHeight - (scrollTop + windowHeight) < 100){
          console.log("you are in the bottom"+_this.$options.name);
          _this.get_spreadtrum_list()
        }
      })
    })
  },
}
</script>
